<template>
    <div class="table">
        <tableLoyout
                :columns="columns"
                :add="addUser"
                :del="delUser"
                :edit="editUser"
                :getlist="getlist" :formItems="formItems" :SelectItems="SelectItems" :modelWidth="700">
        </tableLoyout>
    </div>
</template>
<script lang="ts">
  import { defineComponent, onMounted, ref } from 'vue';
    import tableLoyout from "@/renderer/components/tableLayout/tableLayout.vue";
    import {getlist,addUser,delUser,editUser} from '@/renderer/api/user'
  import { windowShow } from '@/renderer/utils/window';
  import { argsData } from '@/renderer/store';
    export default defineComponent({
        name: 'table',
        components:{tableLoyout},
        setup() {
            const columns = [
                {
                    label:'序号',
                    prop:'date',
                    type:'index',
                    width:'120px',
                    align:'center'
                },
                {
                    label:'用户名',
                    prop:'username'
                },
                {
                    label:'邮箱',
                    prop:'email',
                    align:'center'
                },
                {
                    label:'手机号',
                    prop:'phone',
                    align:'center'
                },
            ]

            const SelectItems = [
                {
                    label:'用户名',
                    key:'username',
                    element:'input'
                }
            ]
            const validatePass = (rule: any, value: any, callback: any) => {
                if (value === '222') {
                    callback(new Error('自定义sword'))
                } else {
                    callback()
                }
            }

            const formItems = [
                {
                    label:'用户名',
                    element:'input',
                    key:'username',
                    span:12,
                    formattributes:{
                        rules:{
                            required: true,
                            message: 'Please input Activity name',
                            trigger: 'blur'
                        }
                    }
                },
                {
                    label:'密码',
                    element:'input',
                    key:'password',
                    span:12,
                    attributes:{
                        type:'password'
                    },
                    formattributes:{
                        rules:{
                            required: true,
                            message: 'Please input Activity name',
                            trigger: 'blur'
                        }
                    }
                },
                {
                    label:'邮箱',
                    element:'input',
                    key:'email',
                    span:12
                },
                {
                    label:'手机号',
                    element:'input',
                    key:'phone',
                    span:12,
                    type:'number'
                }
            ]
          onMounted(() => {
            windowShow(argsData.window.id);
          });
            return {columns,SelectItems,formItems,getlist,addUser,delUser,editUser};
        },
    });
</script>
